﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SMS.Core
{
    class StructClass
    {
    }

    #region PDU码
    /// <summary>
    /// PDU码类型（TPDU的第一个八位位组）
    /// </summary>
    public struct STPDUType
    {
        /// <summary>
        /// 应答路径
        /// </summary>
        public EReplyPath ReplyPath;
        /// <summary>
        /// 用户数据头标识
        /// </summary>
        public EUserDataHeaderIndicator UserDataHeaderIndicator;
        /// <summary>
        /// 状态报告请求
        /// </summary>
        public EStatusReportRequest StatusReportRequest;
        /// <summary>
        /// 状态报告指示，此值仅被短消息服务中心（SMSC）设置
        /// </summary>
        public EStatusReportIndication StatusReportIndication;
        /// <summary>
        /// 有效期格式
        /// </summary>
        public EValidityPeriodFormat ValidityPeriodFormat;
        /// <summary>
        /// 拒绝复本
        /// </summary>
        public ERejectDuplicate RejectDuplicate;
        /// <summary>
        /// 有更多消息需要发送,此值仅被 SMSC 设置
        /// </summary>
        public EMoreMessagestoSend MoreMessagestoSend;
        /// <summary>
        /// 信息类型指示
        /// </summary>
        public EMessageTypeIndicator MessageTypeIndicator;

    }
    /// <summary>
    /// 地址类型
    /// </summary>
    public struct STAddressType
    {
        /// <summary>
        /// 数据类型
        /// </summary>
        public ETypeofNumber TypeofNumber;
        /// <summary>
        /// 号码鉴别
        /// </summary>
        public ENumberingPlanIdentification NumberingPlanIdentification;
    }
    /// <summary>
    /// 数据编码方式
    /// </summary>
    public struct STDataCodingScheme
    {
        /// <summary>
        /// 编码方式的Bit No.7与Bit No.6
        /// </summary>
        public EDefault Default;
        /// <summary>
        /// 文本压缩方式（编码方式的Bit No.5）
        /// </summary>
        public ECompression Compression;
        /// <summary>
        /// 是否包含信息类型信息(编码方式的Bit No.4)
        /// </summary>
        public EMessageType MessageType;
        /// <summary>
        /// 编码方式
        /// </summary>
        public ECodeScheme CodeScheme;
        /// <summary>
        /// 短信类型
        /// </summary>
        public ESMSType SMSType;
    }
    /// <summary>
    /// PDU码配置参数
    /// </summary>
    public struct STPDUParam
    {
        /// <summary>
        /// 【发送/接收】服务中心的电话号码类型
        /// </summary>
        public STAddressType SCAType;
        /// <summary>
        /// 【发送/接收】服务中心的电话号码
        /// </summary>
        public string SCAdress;
        /// <summary>
        /// 【发送/接收】协议数据单元类型,TPDU的第一个八位位组
        /// </summary>
        public STPDUType PDUType;
        /// <summary>
        /// 【发送】消息参考值
        /// </summary>
        public EMessagerefrence MR;
        /// <summary>
        /// 【接收】发送方电话号码类型
        /// </summary>
        public STAddressType OAType;
        /// <summary>
        /// 【接收】发送方电话号码
        /// </summary>
        public string OAdress;
        /// <summary>
        /// 【发送】接收方电话号码类型
        /// </summary>
        public STAddressType DAType;
        /// <summary>
        /// 【发送】接收方电话号码
        /// </summary>
        public string DAdress;
        /// <summary>
        /// 【发送/接收】协议标识，处理短信的方式，如语音、传真等
        /// </summary>
        public EProtocolIdentifier ProtocolIdentifier;
        /// <summary>
        /// 【发送/接收】短信内容编码方式
        /// </summary>
        public STDataCodingScheme DataCodingScheme;
        /// <summary>
        /// 【发送】有效期期限
        /// </summary>
        public string SRValidityPeriod;
        /// <summary>
        /// 【发送】有效期结束日期
        /// </summary>
        public DateTime DTValidityPeriod;
        /// <summary>
        /// 【发送/接收】用户数据
        /// </summary>
        public string UserData;
        /// <summary>
        /// 【接收】指示短信服务中心收到短信的时间。
        /// </summary>
        public DateTime SCTS;
        /// <summary>
        /// PDU码中是否包含服务中心地址
        /// </summary>
        public EISSCA ISSCA;
        /// <summary>
        /// 对该结构体中的各参数进行初始化
        /// </summary>
        /// <param name="b"></param>
        public STPDUParam(bool b)
        {
            #region 中心服务地址
            //中心号码类型
            this.SCAType.TypeofNumber = ETypeofNumber.International;
            this.SCAType.NumberingPlanIdentification = ENumberingPlanIdentification.Phone;
            //中心号码
            this.SCAdress = "8613800771500";
            #endregion

            #region PDU类型
            this.PDUType.ReplyPath = EReplyPath.NO;
            this.PDUType.UserDataHeaderIndicator = EUserDataHeaderIndicator.NO;
            this.PDUType.StatusReportRequest = EStatusReportRequest.NO;
            this.PDUType.ValidityPeriodFormat = EValidityPeriodFormat.integ;
            this.PDUType.RejectDuplicate = ERejectDuplicate.NO;
            this.PDUType.MessageTypeIndicator = EMessageTypeIndicator.SMS_SUBMIT;
            #endregion

            #region 消息参考值
            this.MR = EMessagerefrence.Default;
            #endregion

            #region 接收方地址
            //接收方地址类型
            this.DAType.TypeofNumber = ETypeofNumber.International;
            this.DAType.NumberingPlanIdentification = ENumberingPlanIdentification.Phone;
            //接收方地址
            this.DAdress = "";
            #endregion

            #region 协议标识
            this.ProtocolIdentifier = EProtocolIdentifier.Default;
            #endregion

            #region 数据编码方式
            this.DataCodingScheme.Default = EDefault.Default;
            this.DataCodingScheme.Compression = ECompression.NO;
            this.DataCodingScheme.MessageType = EMessageType.NO;
            this.DataCodingScheme.CodeScheme = ECodeScheme.Unicode;
            this.DataCodingScheme.SMSType = ESMSType.CLASS0;
            #endregion

            #region 有效期
            this.SRValidityPeriod = "255";
            this.DTValidityPeriod = System.DateTime.Now;
            #endregion

            #region 发送的短信内容
            this.UserData = "";
            #endregion

            #region 是否包含中心服务地址
            this.ISSCA = EISSCA.NO;
            #endregion

            #region 发送短信专用参数
            //发送方地址类型
            this.OAType.TypeofNumber = ETypeofNumber.International;
            this.OAType.NumberingPlanIdentification = ENumberingPlanIdentification.Phone;
            //发送方地址
            this.OAdress = "";
            //短信中心收到短信的时间
            this.SCTS = System.DateTime.Now;
            //PDU类型
            this.PDUType.MoreMessagestoSend = EMoreMessagestoSend.NO;
            this.PDUType.StatusReportIndication = EStatusReportIndication.NO;
            #endregion
        }

    }
    /// <summary>
    /// 待发送的PDU码及其长度
    /// </summary>
    public struct STPDU
    {
        /// <summary>
        /// 待发送的PDU码字符串
        /// </summary>
        public string strPDU;
        /// <summary>
        /// PDU码长度，15+短信内容字节数
        /// </summary>
        public int lenPDU;
    }
    /// <summary>
    /// 接收到的短信及发送方电话号码
    /// </summary>
    public struct STSMS
    {
        public string SMS;
        public string PHONE;
    }

    /// <summary>
    /// 串口操作中涉及到的相关参数
    /// </summary>
    public struct STCommParam
    {
        /// <summary>
        /// 缓冲发送的命令
        /// </summary>
        public string SendCommand;
        /// <summary>
        /// 缓冲发送命令中的关键字
        /// </summary>
        public string SendKeyWord;
        /// <summary>
        /// 接收到短信的标识，同时也是所接收短信在模块存储器中的位置
        /// </summary>
        public string RecvFlag;
        /// <summary>
        /// 是否在处理串口控件的接收事件中处理接收数据
        /// </summary>
        public bool CommRecvEvent;
        /// <summary>
        /// 接收事件中等待时间
        /// </summary>
        public int RecvWaitTime;
        /// <summary>
        /// 发送命令重试次数
        /// </summary>
        public int ReTryNum;

        public STCommParam(bool b)
        {
            this.CommRecvEvent = true;
            this.RecvFlag = "";
            this.SendCommand = "";
            this.SendKeyWord = "";
            this.RecvWaitTime = 100;
            this.ReTryNum = 0;
        }
    }
    #endregion
}
